﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DTOSingTowerMall.SearchModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Store
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%=Model.CategoryName%>:Store</h2>
   <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.autocomplete.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="/Scripts/jquery.autocomplete.css" />
                <table>
                    <tr>
<%--  =======================================Show ViewAll item on the main view===================--%>                      
                        <td>
                             <%: Ajax.ActionLink("ViewAll", "Store", new { categoryName = Model.CategoryName }, new AjaxOptions { UpdateTargetId = "SearchResult" })%> |
                          <%--   <%: Html.ActionLink("ViewAll", "Store", new { categoryName = Model.CategoryName })%> |--%>
                       </td>
<%--  =======================================Show The other subcategory items on the main view=====--%>                    
                       <td>
                       <% if (Model.SubCategoryList != null) { %>
                              <% foreach (var item in Model.SubCategoryList) { %>              
<%--                              <%: Html.ActionLink(item.SubCategoryName, "Store", new { subcategoryID = item.SubCategoryID, categoryID = item.CategoryID, categoryName = Model.CategoryName })%> |--%>
                              <%: Ajax.ActionLink(item.SubCategoryName, "Store", new { subcategoryID = item.SubCategoryID, categoryID = item.CategoryID, categoryName = Model.CategoryName }, new AjaxOptions { UpdateTargetId = "SearchResult" })%> |
                              <% } %>
                       <%} %>                                  
                       </td> 
                   </tr>
                 </table>

 <%--  =======================================Show Stores by Name(TextBox) on the main view=========--%> 
  <% if (Model.CategoryName == null) { %>
    <% using (Ajax.BeginForm("Store","store",null, new AjaxOptions { UpdateTargetId = "SearchResult" }))
       { %>
        <%= Html.TextBox("StoreName", null, new { size = 40 })%>    
        <input type="submit" value="Search" />
        <br />
    <% } %>
  <%} %>  
<%--  =======================================Show LevelView (DroupDownList) on the main view=======--%>
    <% using (Ajax.BeginForm("store", "store", new { categoryName = Model.CategoryName }, new AjaxOptions { UpdateTargetId = "SearchResult" }))
           //using (Html.BeginForm("store","store",new {categoryName=Model.Category}))
           //using (Html.BeginForm())
        {
            if (Model.CategoryName == null)
            {
           %>

    <fieldset>
        <p>
            <%= Html.DropDownListFor(m => m.Level, (SelectList)Session["LevelList"], "--LevelView--")%>
            <input type="submit" name="SearchButton" value="Submit" />
        </p>
        <p style="font-size:xx-small">Main View: drop down generated on <%=DateTime.Now%></p>

    </fieldset>
    <%} %>
<%--  =======================================Show Partial View (Show Stores) on the main view =======--%>
        <div id="SearchResult">
            <%if (Model.StoreList != null && Model.StoreList.Count() > 0)
              {
                  Html.RenderPartial("SearchResult", Model.StoreList);
              }
            %>
        </div>

    <%} %>

<%--  =======================================Jquery =============================================--%>
          <script type="text/javascript">
              $(document).ready(function () { $("#StoreName").autocomplete('<%=Url.Content("~/Store/StoreList") %>') });
              $(document).ready(function () { jQuery("#StoreName").attr('x-webkit-speech', 'x-webkit-speech'); });
          </script>
</asp:Content>

